<template>
  <ul class="todo-list">
    <!-- completed: 完成的类名 -->
    <li :class="item.isDone ? 'completed' : ''"  v-for="(item,index) in list" :key="item.id">
      <div class="view">
        <input class="toggle" type="checkbox" v-model="item.isDone" @click="setList(index)" />
        <label>{{item.name}}</label>
        <button class="destroy" @click="delList(index)"></button>
      </div>
    </li>
  </ul>
  
</template>

<script>
import { mapGetters} from 'vuex'
export default {
  computed: {
    ...mapGetters(['list'])
  },
  methods: {
    setList(index) {
      this.$store.commit('todomain/setList',index)
    },
    delList(index){
      this.$store.commit('todomain/delList',index)
    },
  }
}
</script>
